import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class TopicItem {
  TopicItem(this.nicname, this.agrees, this.timeTag, this.avatarUrl, this.topic,
      this.topicImgs, this.views, this.comments);
  String nicname; //用户昵称
  String timeTag; //时间
  String avatarUrl; //用户头像
  String topic; //文章内容
  var topicImgs = []; //文章配图
  String views; //浏览量
  String agrees; //点赞量
  var comments = [];
  String comment = "评论内容"; //评论信息

  Widget getItemView() {
    return Padding(
      // ignore: prefer_const_constructors
      padding: EdgeInsets.fromLTRB(30, 20, 30, 0),
      child: BrnShadowCard(
        padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
        color: Colors.white,
        circular: 10,
        child: Column(
          children: [
            Row(
              children: [
                ClipRRect(
                  borderRadius: const BorderRadius.all(Radius.circular(50)),
                  child: Image.network(
                    "https://img2.baidu.com/it/u=2563905782,171946313&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500",
                    width: 40,
                    height: 40,
                  ),
                ),
                Text(nicname,
                    style: const TextStyle(
                        color: Colors.black,
                        fontSize: 16,
                        fontWeight: FontWeight.w800)),
                Text(
                  timeTag,
                  style: const TextStyle(
                      color: Color.fromARGB(255, 146, 146, 146),
                      fontSize: 14,
                      fontWeight: FontWeight.w100),
                )
              ],
            ),
            SizedBox(
              width: double.infinity,
              child: Text(topic),
            ),
            SizedBox(
              height: 300,
              width: double.infinity,
              child: Row(
                children: getTopicImgs(),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text("浏览了$views次"),
                Row(
                  // ignore: prefer_const_constructors
                  children: [const Icon(Icons.grade_rounded), Text(agrees)],
                )
              ],
            ),
          ],
        ),
      ),
    );
  }

  List<Widget> getTopicImgs() {
    List<Widget> wgt = [];
    for (var url in topicImgs) {
      print(
          "$url..........................................................................");
      wgt.add(Image.network(
        url,
      ));
    }
    return wgt;
  }
}
